package mysql

import (
	"gorm.io/gorm"
)

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(30);unique;not null;" json:"username" `
	Password string `gorm:"type:varchar(36);not null;" json:"password"`
}

func (u *User) FindUserByUsername(username string) (user *User, err error) {
	err = DB.Where("username=?", username).Find(&u).Error
	if err != nil {
		return nil, err
	}
	return u, nil
}
func (u *User) CreateUserUsernameAndPassword() error {

	err := DB.Debug().Create(&u).Error
	if err != nil {
		return err
	}
	return nil
}
